﻿@page "/OvenPage"
@inject OvenServer ovenServer
@using System.ComponentModel
@using AntDesign.TableModels
@inject ModalService _modalService
@inject MessageService _message
<h3>烘箱出料</h3>
<div>
    <Row>
        <Col Span="24">请选择烘箱</Col>
    </Row>
    <Row>
        <Col Span="24">
        <Select style="width:100%" DataSource="@DataList"
                AllowClear="true"
                ValueOnClear="@(0)"
                @bind-Value="@selet"
                ValueName="@nameof(Oven_Entity.Deviceid)"
                LabelName="@nameof(Oven_Entity.Remark)">
        </Select>
        </Col>
    </Row>
    <Row>
        <Col Span="24"> <label>请选择满缓存架</label></Col>
    </Row>
    <Row>
        <Col Span="24">
        <Select style="width:100%" DataSource="@FullCaches"
                AllowClear="true"
                ValueOnClear="@(0)"
                @bind-Value="@FullCacheselet"
                ValueName="@nameof(FullCache_Entity.Deviceid)"
                LabelName="@nameof(FullCache_Entity.Remark)">
        </Select>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <label>烘箱号</label>
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <Input style="width:100%" Placeholder="Basic usage" @bind-Value="@index" />
        </Col>
    </Row>
    <Row>
        <Col Span="24">
        <label>是否指定缓存架编号</label>
        </Col>
    </Row>

    <Row>
        <Col Span="8" Push="8">
        <Switch style="width:100%" @bind-Value="@Flag"></Switch>
        </Col>
    </Row>
    <br>
    <Row>
        <Col Span="24">
        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@Creat">提交烘箱出料任务</Button>
        </Col>
    </Row>
</div>

@code {
    ObservableCollection<Oven_Entity> DataList { get; set; } = new ObservableCollection<Oven_Entity>();
    ObservableCollection<FullCache_Entity> FullCaches { get; set; } = new ObservableCollection<FullCache_Entity>();
    int selet { get; set; } = 0;
    int index { get; set; } = 0;
    int FullCacheselet { get; set; } = 0;
    bool Flag { get; set; } = false;

    protected override async Task OnInitializedAsync()
    {
        var Ovens = await ovenServer.Getlist();
        if (Ovens != null)
        {
            DataList.Clear();
            foreach (var item in Ovens)
            {
                DataList.Add(item);
            }
        }
        var fullCaches = await ovenServer.GetFull();
        if (fullCaches != null)
        {
            FullCaches.Clear();
            foreach (var item in fullCaches)
            {
                FullCaches.Add(item);
            }
        }

        base.OnInitialized();
    }
    private async Task Creat()
    {
        _modalService.Confirm(new ConfirmOptions()
        {
            Title = "提示",
            Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
            OkText = "确认",
            OnOk = async (e) =>
            {
            int a = selet;
            int c = index;
            var aa = await ovenServer.TaskCreat(selet, index);
            _message.Info(aa);
            },
            CancelText = "取消",
            Content = "是否提交？",
            });



}
}
